/*
 * GameHexTester.fx
 *
 * Created on Sep 5, 2009, 2:01:26 PM
 */

package fxbattle.fxgui;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.Group;
import javafx.scene.transform.Transform;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;
import fxbattle.client.model.Direction;
import javafx.scene.paint.Color;
import javafx.scene.effect.ColorAdjust;

/**
 * @author spina
 */

var simpleHexGroup = Group{
    //transforms: [Transform.translate(100, 100)]
    content: []
}

var unoccupiedHex = GameHexagon{transforms: [GameHexagon.createTranslation(0, 1)]}
var armySizeHex = GameHexagon{armySize: .5; transforms: [GameHexagon.createTranslation(1, 1)]};
var northHex = GameHexagon{transforms: [GameHexagon.createTranslation(1, 2)]};
var elevationHex = GameHexagon{ elevationPercent: 0 transforms: [GameHexagon.createTranslation(1, 3)]};
var baseHex = GameHexagon{isBase: true transforms: [GameHexagon.createTranslation(1, 4)]};
var visibilityHex = GameHexagon{visible: bind alternatingBoolean transforms: [GameHexagon.createTranslation(2, 1)]};

Timeline {
    repeatCount: Timeline.INDEFINITE
    keyFrames : [
        KeyFrame {
            time : .5s
            values: elevationHex.elevationPercent => .2;
        }
        KeyFrame {
            time : 1.5s
        }
        KeyFrame {
            time : 2s
            values: elevationHex.elevationPercent => .8;
        }
    ]
}.playFromStart();
Timeline {
    repeatCount: Timeline.INDEFINITE
    autoReverse: true
    keyFrames : [
        KeyFrame {
            time : .5s
            values: armySizeHex.armySize => 0;
        }
        KeyFrame {
            time : 1.5s
        }
        KeyFrame {
            time : 2s
            values: armySizeHex.armySize => 1;
        }
    ]
}.playFromStart();

var alternatingBoolean = false on replace {
      baseHex.isBase = alternatingBoolean;
      if(alternatingBoolean) {
          insert Direction.NORTH into northHex.activeDirections;
          armySizeHex.armyColor = Color.BLUE;
      } else {
          delete Direction.NORTH from northHex.activeDirections;
          armySizeHex.armyColor = Color.RED;
      }};
Timeline {
    repeatCount: Timeline.INDEFINITE
    keyFrames : [
        KeyFrame {
            time : .5s
            values: alternatingBoolean => true;
        }
        KeyFrame {
            time : 1s
            values: alternatingBoolean => false;
        }
    ]
}.playFromStart();

insert unoccupiedHex into simpleHexGroup.content;
insert northHex into simpleHexGroup.content;
insert armySizeHex into simpleHexGroup.content;
insert elevationHex into simpleHexGroup.content;
insert baseHex into simpleHexGroup.content;
insert visibilityHex into simpleHexGroup.content;
insert FlowArrow {
    visible: true //bind Sequences.indexOf(activeDirections, dir) != -1;
    length : 40
    strokeWidth: 4
    stroke: bind Color.RED
    effect: ColorAdjust {
            brightness: -.2
            contrast: 1
            hue: 0.0
            saturation: 0.0
        }


    transforms : [GameHexagon.createTranslation(2, 2), Transform.rotate(Direction.NORTH.angle() - 90, 0, 0)]
} into simpleHexGroup.content;
Stage {
    title: "Application title"
    width: 400
    height: 400
    scene: Scene {
        content: [
            simpleHexGroup
            ]
    }
}